//
//  JLSHeadlineCell.m
//  看点
//
//  Created by 焦林生 on 15/12/18.
//  Copyright © 2015年 jiaolinsheng. All rights reserved.
//

#import "JLSHeadlineCell.h"
#import "UIImageView+WebCache.h"
#import "JLSHeadline.h"

@interface JLSHeadlineCell ()
//3条线
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
//2条线
@property (weak, nonatomic) IBOutlet UILabel *detailTitleLabel;
//3条线
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
/**
 *  第二张图片
 */
@property (weak, nonatomic) IBOutlet UIImageView *imageViewTwo;
/**
 *  第三张图片
 */
@property (weak, nonatomic) IBOutlet UIImageView *imageViewThree;
//3条线
@property (weak, nonatomic) IBOutlet UILabel *replyLabel;

@end
@implementation JLSHeadlineCell

+ (NSString *)headlineCellWithIdentifier:(JLSHeadline *)headline
{

    if (headline.imgextra.count == 2) {
        return @"ImagesCell";
    }
    if (headline.isBigImaga) {
        return @"BigImageCell";
    }
    return @"NewsCell";
    
}

- (void)setHeadline:(JLSHeadline *)headline
{
    _headline = headline;
    
    
    
    
    // 为子控件设置数据
    self.titleLabel.text = headline.title;
    self.detailTitleLabel.text = headline.digest;
    self.replyLabel.text = [NSString stringWithFormat:@"%d跟帖",headline.replyCount];
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:headline.imgsrc] placeholderImage:[UIImage imageNamed:@"loading"]];
    
    // 如果是三张图片的cell模板时,需要为其它两个图片框设置图片
    if (headline.imgextra.count == 2) {
        
        // 设置第二张图片
        NSString *urlStringTwo = headline.imgextra[0][@"imgsrc"];
        [self.imageViewTwo sd_setImageWithURL:[NSURL URLWithString:urlStringTwo] placeholderImage:[UIImage imageNamed:@"loading"]];
        
        // 设置第三张图片
        NSString *urlStringThree = headline.imgextra[1][@"imgsrc"];
        [self.imageViewThree sd_setImageWithURL:[NSURL URLWithString:urlStringThree] placeholderImage:[UIImage imageNamed:@"loading"]];
    }
}


- (void)awakeFromNib {
    // Initialization code
}



@end
